package com.cxx.purchasecharge.dal;

import java.util.Date;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import com.cxx.purchasecharge.core.model.OrderSearchForm;
import com.cxx.purchasecharge.core.model.OrderStatusCode;
import com.cxx.purchasecharge.core.model.OrderTypeCode;
import com.cxx.purchasecharge.core.model.persistence.Order;
import com.cxx.purchasecharge.dal.common.MyGenericDao;
import com.cxx.purchasecharge.dal.exception.PCDalException;

public interface OrderDao extends MyGenericDao<Order, Long> {

	public List<Order> findByCustomerName(String customerName);

	public List<Order> findByCustomerId(long customerId);

	public List<Order> findByOrderStatusCode(OrderStatusCode statusCode);

	public List<Order> findByUserSigned(long userId);

	public List<Order> findByRangeCreateDate(OrderTypeCode typeCode,
			OrderStatusCode statusCode, Date start, Date end);

	public int updateStatus(OrderStatusCode statusCode, String comment, long id);

	public int updateProfit(float profit, long id);

	public int updateReceivable(float receivable, long id);

	public Page<Order> findByFuzzy(OrderTypeCode typeCode, Pageable pageable,
			String searchKey, long signUser, boolean admin)
			throws PCDalException;

	public Page<Order> findBySearchForm(OrderTypeCode typeCode,
			Pageable pageable, OrderSearchForm searchForm, long signUser,
			boolean admin) throws PCDalException;

	public Page<Order> findBySearchForm(boolean out, Pageable pageable,
			OrderSearchForm searchForm, long signUser, boolean admin)
			throws PCDalException;

	public float countReceivableBy(OrderTypeCode typeCode,
			OrderSearchForm searchForm, long signUser, boolean admin)
			throws PCDalException;

	public float countProfitBy(OrderTypeCode typeCode,
			OrderSearchForm searchForm, long signUser, boolean admin)
			throws PCDalException;
}
